home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / Graphic Gems I, II & III (C_C++) / Graphics Gems C Code.sea / GemsI / Src / PolyScan / poly.c < prev    next >
Text File  |  1992-06-16  |  2KB  |  75 lines

  1. /*
  2.  * poly.c: simple utilities for polygon data structures
  3.  */
  4.  
  5. #include "poly.h"
  6.  
  7. Poly_vert *poly_dummy;        /* used superficially by POLY_MASK macro */
  8.  
  9. /*
  10.  * poly_print: print Poly p to stdout, prefixed by the label str
  11.  */
  12.  
  13. void poly_print(str, p)
  14. char *str;
  15. Poly *p;
  16. {
  17.     int i;
  18.  
  19.     printf("%s: %d sides\n", str, p->n);
  20.     poly_vert_label("        ", p->mask);
  21.     for (i=0; i<p->n; i++) {
  22.     printf("   v[%d] ", i);
  23.     poly_vert_print("", &p->vert[i], p->mask);
  24.     }
  25. }
  26.  
  27. void poly_vert_label(str, mask)
  28. char *str;
  29. int mask;
  30. {
  31.     printf("%s", str);
  32.     if (mask&POLY_MASK(sx))   printf("   sx  ");
  33.     if (mask&POLY_MASK(sy))   printf("   sy  ");
  34.     if (mask&POLY_MASK(sz))   printf("   sz  ");
  35.     if (mask&POLY_MASK(sw))   printf("   sw  ");
  36.     if (mask&POLY_MASK(x))    printf("   x   ");
  37.     if (mask&POLY_MASK(y))    printf("   y   ");
  38.     if (mask&POLY_MASK(z))    printf("   z   ");
  39.     if (mask&POLY_MASK(u))    printf("   u   ");
  40.     if (mask&POLY_MASK(v))    printf("   v   ");
  41.     if (mask&POLY_MASK(q))    printf("   q   ");
  42.     if (mask&POLY_MASK(r))    printf("   r   ");
  43.     if (mask&POLY_MASK(g))    printf("   g   ");
  44.     if (mask&POLY_MASK(b))    printf("   b   ");
  45.     if (mask&POLY_MASK(nx))   printf("   nx  ");
  46.     if (mask&POLY_MASK(ny))   printf("   ny  ");
  47.     if (mask&POLY_MASK(nz))   printf("   nz  ");
  48.     printf("\n");
  49. }
  50.  
  51. void poly_vert_print(str, v, mask)
  52. char *str;
  53. Poly_vert *v;
  54. int mask;
  55. {
  56.     printf("%s", str);
  57.     if (mask&POLY_MASK(sx)) printf(" %6.1f", v->sx);
  58.     if (mask&POLY_MASK(sy)) printf(" %6.1f", v->sy);
  59.     if (mask&POLY_MASK(sz)) printf(" %6.2f", v->sz);
  60.     if (mask&POLY_MASK(sw)) printf(" %6.2f", v->sw);
  61.     if (mask&POLY_MASK(x))  printf(" %6.2f", v->x);
  62.     if (mask&POLY_MASK(y))  printf(" %6.2f", v->y);
  63.     if (mask&POLY_MASK(z))  printf(" %6.2f", v->z);
  64.     if (mask&POLY_MASK(u))  printf(" %6.2f", v->u);
  65.     if (mask&POLY_MASK(v))  printf(" %6.2f", v->v);
  66.     if (mask&POLY_MASK(q))  printf(" %6.2f", v->q);
  67.     if (mask&POLY_MASK(r))  printf(" %6.4f", v->r);
  68.     if (mask&POLY_MASK(g))  printf(" %6.4f", v->g);
  69.     if (mask&POLY_MASK(b))  printf(" %6.4f", v->b);
  70.     if (mask&POLY_MASK(nx)) printf(" %6.3f", v->nx);
  71.     if (mask&POLY_MASK(ny)) printf(" %6.3f", v->ny);
  72.     if (mask&POLY_MASK(nz)) printf(" %6.3f", v->nz);
  73.     printf("\n");
  74. }
  75.